package com.neusoft.java;

/**
 * @author shkstart
 * @create 2021-08-03 20:43
 */
public class TreeMain {
    public static void main(String[] args) {
        TreeNode t1=new TreeNode("A");
        TreeNode t2=new TreeNode("B");
        TreeNode t3=new TreeNode("C");
        TreeNode t4=new TreeNode("D");
        TreeNode t5=new TreeNode("E");
        TreeNode t6=new TreeNode("F");
        //A
        t1.left=t2;
        t1.right=t3;

        //B
        t2.left=t4;
        t2.right=t5;


        //C
        t3.left=t6;
//        preOrderRe(t1);
//        midOrderRe(t1);
        postOrderRe(t1);
    }


    public static void preOrderRe(TreeNode biTree){
        //递归调用
        System.out.println(biTree.value);
        TreeNode leftTree=biTree.left;
        if(leftTree!=null){
            preOrderRe(leftTree);
        }

        TreeNode rightTree=biTree.right;
        if(rightTree!=null){
            preOrderRe(rightTree);
        }

    }

    public static void midOrderRe(TreeNode biTree){
        if(biTree==null){
            return;
        }else {
           midOrderRe(biTree.left);
            System.out.println(biTree.value);
            midOrderRe(biTree.right);
        }

       }

    public static void postOrderRe(TreeNode biTree){
        if(biTree==null){
            return;
        }else {
            midOrderRe(biTree.left);
            midOrderRe(biTree.right);
            System.out.println(biTree.value);
        }

    }
}
